﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FitnessMVC.Data
{
    public partial class UserProfile
    {
        public bool IsValid 
        {
            get { return (GetRuleViolations().Count() == 0); }
        }

        public IEnumerable<RuleViolation> GetRuleViolations()
        {
            if (String.IsNullOrEmpty(FirstName))
                yield return new RuleViolation("First Name is required", "FirstName");
            if (String.IsNullOrEmpty(LastName))
                yield return new RuleViolation("Last Name is required", "LastName");
            if (String.IsNullOrEmpty(AboutMe))
                yield return new RuleViolation("Tell us about yourself", "AboutMe");
            if (BirthDate == null || BirthDate == new DateTime())
                yield return new RuleViolation("Please supply a birthday... don't worry, we won't tell...", "BirthDate");
            if (String.IsNullOrEmpty(Hometown))
                yield return new RuleViolation("Let us know where you're from so we can find people near you...", "Hometown");            
        }
    }
}
